home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-12-12 | 3.0 KB | 108 lines |
- /*
- * Copyright(C) 1996 Sony Corporation. All rights reserved.
- */
-
- import vrml.*;
- import vrml.field.*;
- import vrml.node.*;
- import java.util.*;
- import vs.*;
-
- public class guess extends Script{
- /* Node */
- SFNode GuessNode;
-
- /* EventOut */
- SFString GuessAppearanceDescription;
- SFBool GuessTimeSensorEnabled;
- public void initialize() {
- /* Node */
- GuessNode = (SFNode) getField( "GuessNode" );
-
- /* EventOut */
- GuessAppearanceDescription = (SFString) getEventOut( "GuessAppearanceDescription" );
- GuessTimeSensorEnabled = (SFBool) getEventOut( "GuessTimeSensorEnabled" );
- }
-
- public void processEvent(Event e) {
- String name = e.getName () ;
-
- if(name.equals("GuessTouchSensorIsActive")) { GuessTouchSensorIsActive(e); }
- if(name.equals("GuessPlaneSensorIsActive")) { GuessPlaneSensorIsActive(e); }
- if(name.equals("GuessShareTouched")){ GuessShareTouched(e); }
- }
-
- public void GuessTouchSensorIsActive(Event e) {
- double time = e.getTimeStamp();
- ConstSFBool mouse_down = (ConstSFBool)e.getValue();
-
- if (mouse_down.getValue()) { /* mouseDown */
- GuessTimeSensorEnabled.setValue(true);
- } else {
- GuessTimeSensorEnabled.setValue(false);
- GuessCommentDisplay();
- Vscp.sendApplSpecificMsgWithDist( GuessNode, "GuessShareTouched", "void", Vscp.allClientsExceptMe );
- }
- }
-
- public void GuessPlaneSensorIsActive(Event e) {
- double time = e.getTimeStamp();
- ConstSFBool mouse_down = (ConstSFBool)e.getValue();
-
- if (mouse_down.getValue()) return; /* mouseDown */
-
- GuessCommentDisplay();
- Vscp.sendApplSpecificMsgWithDist( GuessNode, "GuessShareTouched", "void", Vscp.allClientsExceptMe );
- }
-
-
- public void GuessShareTouched(Event e) {
- //double time = e.getTimeStamp();
-
- GuessCommentDisplay();
-
- }
-
- public void GuessCommentDisplay () {
- String txt = "";
- int num;
-
- num = randMinMax(0, 8);
- switch (num) {
- case 0: txt = "Welcome!!\nYour name is "; break;
- case 1: txt = "There is a light switch in this room. \nLet's turn off the light.\n"; break;
- case 2: txt = "Looking good!\n"; break;
- case 3: txt = "Hi!\nGo to the second floor! \nYou can climb the stairs.\n"; break;
- case 4: txt = "You can fly.\nCtrl+Click on the roof!\n"; break;
- case 5: txt = "To play a game,\nGo to the Bouncing Room!\n"; break;
- case 6: txt = "To leave your own message,\nGo to the White Board Room.\n"; break;
- case 7: txt = "There is an object which tells you your lucky color\nin this room!\n"; break;
- case 8: txt = "In this room, \nAn elevator object is available.\n"; break;
- }
- /*
- switch $mode {
- 0 { set t "I Guess your name .." }
- 1 { set t "$s$name" }
- }
- */
- //GuessTimeSensorEnabled.setValue(true);
- GuessAppearanceDescription.setValue(txt);
-
- }
-
- int randMinMax(int min,int max){
- int value;
- int range;
- double rnd;
-
- range = max - min;
- rnd = Math.random();
- value = (int)(rnd * (double)range) + min;
-
- return value;
- }
- }
-
-
-
-